package com.ruoyi.project.hissystem.conterllor;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.hissystem.domain.RegistrationCost;
import com.ruoyi.project.hissystem.domain.SysExamCost;
import com.ruoyi.project.hissystem.service.ISysRegistrationCostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/system/ghmoney")
public class SysRegistrationCostController extends BaseController {
    @Autowired
    private ISysRegistrationCostService iSysRegistrationCostService;
    @PreAuthorize("@ss.hasPermi('system:ghmoney:list')")
    @GetMapping("/index")
    @ResponseBody
    public TableDataInfo list(RegistrationCost registrationCost) {
        startPage();
        List<RegistrationCost> registrationCosts = iSysRegistrationCostService.selRegistrationCostList(registrationCost);
        return getDataTable(registrationCosts);
    }


    /**
     * 新增挂号费用
     */
    @PreAuthorize("@ss.hasPermi('system:ghmoney:add')")
    @Log(title = "挂哈费用管理", businessType = BusinessType.INSERT)
    @PostMapping("add")
    @ResponseBody
    public AjaxResult add(@RequestBody RegistrationCost registrationCost)
    {

        registrationCost.setCreateBy(SecurityUtils.getUsername());
        return toAjax(iSysRegistrationCostService.insRegistrationCost(registrationCost));
    }

    /*根据id查询*/

    @PreAuthorize("@ss.hasPermi('system:ghmoney:query')")
    @GetMapping(value = "/{regid}")
    @ResponseBody
    public AjaxResult getInfo(@PathVariable int regid)
    {
        return AjaxResult.success(iSysRegistrationCostService.selRegistrationCostOne(regid));
    }


    /*修改挂号费用*/
    @PreAuthorize("@ss.hasPermi('system:ghmoney:edit')")
    @Log(title = "挂号费用项目管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ResponseBody
    public AjaxResult edit(@RequestBody RegistrationCost registrationCost)
    {

        registrationCost.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(iSysRegistrationCostService.upRegistrationCost(registrationCost));
    }


    /*删除挂号费用项目信息*/

    @PreAuthorize("@ss.hasPermi('system:ghmoney:remove')")
    @Log(title = "挂号费用项目管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{regids}")
    @ResponseBody
    public AjaxResult remove(@PathVariable int[] regids)
    {
        return toAjax(iSysRegistrationCostService.delRegistrationCost(regids));
    }

}
